#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define DEBUG 0
#define SHOWPERMUTATIONS 1

using namespace std;
typedef vector<string>::iterator ivs;

vector<string> words;

string stringLowerCase(string s)
{
  string r = "";
  for(int i=0; i<s.size(); i++)
  {
    if(s[i] < 97)
      r+=(s[i] + 32);
    else
      r+=s[i];
  }
  return r;
}

bool caseInsensitiveStringCompare(const string s1, const string s2)
{
    return stringLowerCase(s1) < stringLowerCase(s2);
}

int isAnanagram(string chars,
                string permutation,
                ivs ini,
                ivs fin)
{
    if(chars.size() == 1 && permutation.size() == 0)
        return 1;
    
    if(chars.size() == 1)
    {
        int r = 1;
        permutation = permutation + chars;
        if(DEBUG && SHOWPERMUTATIONS) cout<<"permutation: "<<permutation<<endl;
        for(ivs i = ini; i < fin; i++)
            if( 
                permutation.size() == (*i).size()
                && permutation == stringLowerCase((*i))
                )
            {
                if(DEBUG) cout<<"delete permutation: "<<permutation<<endl;
                words.erase(i--);
                r = 0;
            }
        return r;
    }
    
    ivs nini = (ivs)0, nfin = (ivs)0;
    if(DEBUG && SHOWPERMUTATIONS) cout<<"partial permutation: '"<<stringLowerCase(permutation)<<"'"<<endl;
    for(ivs i = ini; i < fin; i++)
        if(permutation == stringLowerCase((*i).substr(0,permutation.size())))
        {
            if(DEBUG && SHOWPERMUTATIONS) cout<<stringLowerCase((*i))<<endl;
            if(nini == (ivs)0)
            {
                nini = i;
                nfin = nini + 1;
            }
            else
                nfin = i + 1;
        }

    if(nini == (ivs)0) return 1;
    
    int r = 1, rcall;
    for(int i = 0; i < chars.size(); i++)
    {
        rcall = isAnanagram(
                        chars.substr(0,i) + chars.substr(i+1),
                        permutation + chars[i],
                        nini,
                        nfin
                        );
        r = r && rcall;
        if(rcall == 0) rcall--;
    }
    return r;
}

int main()
{
    string word;
    vector<string> ananagrams;
    
    while(true)
    {
        cin>>word;
        if(word == "#") break;
        words.push_back(word);
    }
    
    sort(words.begin(), words.end(), caseInsensitiveStringCompare);
    
    if(DEBUG)
    {
        cout<<"sorted case-insensitive words: "<<endl;
        for(int i = 0; i < words.size(); i++)
            cout<<words[i]<<endl;
    }
    
    while(words.size())
    {
        word = words[0];
        words.erase(words.begin());
        if(DEBUG) cout<<endl<<"ananagram?: "<<word<<endl;
        if(isAnanagram(stringLowerCase(word), "", words.begin(), words.end()))
            ananagrams.push_back(word);
    }
    
    sort(ananagrams.begin(), ananagrams.end());

    if(DEBUG) cout<<endl<<"sorted ananagrams: "<<endl;    
    for(int i = 0; i < ananagrams.size(); i++)
        cout<<ananagrams[i]<<endl;
    
    return 0;
}
